package com.summba.main.test;

import java.io.BufferedReader;
import java.io.File;
import java.util.Iterator;
import java.util.List;

import com.summba.common.Common;
import com.summba.common.GetResource;
import com.summba.corpus.extractor.KeywordExtractor;

public class KWExtractor {
	private static String corpusFloder ;
	private static String saveFile;

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{
		GetResource res = new GetResource();
		corpusFloder = res.getCorpusPathFloder();
		saveFile = res.getKeyResSave();
		BufferedReader br = Common.getFileInfo(
				System.getProperty("user.dir")+File.separatorChar+"conf"+
				File.separatorChar+"keyword.properties");
		//System.out.println(System.getProperty("user.dir")+File.separatorChar+"conf"+
				//File.separatorChar+"keyword.properties"+"!!");
		List<String> tempList = Common.bufferedReaderToList(br);
		//System.out.println("tempList.size(): "+tempList.size());
		
		System.out.println("KWExtractor is Start");
		List<String> tempFileList = Common.getFloderAllFileList(corpusFloder, true);
		for (Iterator<String> iterator = tempFileList.iterator(); iterator.hasNext();) {
			String string = (String) iterator.next();
			//System.out.println("string "+string);
			KeywordExtractor instance = new KeywordExtractor(string,saveFile);
			for (Iterator<String> keywordIterator = tempList.iterator(); keywordIterator.hasNext();) {    
				String keyword = (String) keywordIterator.next(); 
				//System.out.println("keyword "+keyword);
				instance.getTextContent(keyword);                                            
			}  
			instance.GenFile();
		}
		System.out.println("KWExtractor is End");
	}

}
